package main

import "container/list"

type RecentCounter struct {
	queue *list.List
}

func Constructor() RecentCounter {
	counter := RecentCounter{}
	counter.queue = list.New()
	return counter
}

func (this *RecentCounter) Ping(t int) int {
	left := t - 3000
	queue := this.queue
	queue.PushBack(t)
	for queue.Front().Value.(int) < left {
		queue.Remove(queue.Front())
	}
	return queue.Len()
}

/**
 * Your RecentCounter object will be instantiated and called as such:
 * obj := Constructor();
 * param_1 := obj.Ping(t);
 */
